#ifndef QEMU_LBC_H
#define QEMU_LBC_H

#include "hw/qdev-core.h"
#include "exec/memory.h"

#define TYPE_LBC_SLAVE "lbc_slave"
#define LBC_SLAVE_CLASS(kclass) OBJECT_CLASS_CHECK(LBCSlaveClass, (kclass), TYPE_LBC_SLAVE)
#define LBC_SLAVE(obj) OBJECT_CHECK(LBCSlave, (obj), TYPE_LBC_SLAVE)
#define LBC_SLAVE_GET_CLASS(obj) OBJECT_GET_CLASS(LBCSlaveClass, (obj), TYPE_LBC_SLAVE)


#define TYPE_LBC_BUS "localbus"
#define LBC_BUS(obj) OBJECT_CHECK(LBCBus, (obj), TYPE_LBC_BUS)



typedef struct {
    DeviceState qdev;
} LBCSlave;

typedef struct LBCSlaveClass {
    DeviceClass parent_class;
    int (*send)(LBCSlave *s, hwaddr addr, uint32_t data);
    uint32_t (*recv)(LBCSlave *s, hwaddr addr);
} LBCSlaveClass;

typedef struct {
    BusState qbus;
    LBCSlave *current_devs;
} LBCBus;

LBCBus *localbus_init_bus(DeviceState *parent, const char *name);
int localbus_send(LBCBus *bus, hwaddr addr, uint32_t data);
uint32_t localbus_recv(LBCBus *bus, hwaddr addr);

#endif